<?php
// +----------------------------------------------------------------------
// | 多客怪兽框架多平台开发框架 [ 以下开发工具自动生成-版权勿删 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021~2024 http://www.dkyx.cc All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 刘泓宾（514660094@qq.com）
// +----------------------------------------------------------------------

namespace addons\cloud_market\model;

use think\model\concern\SoftDelete;

/**
 * 站点应用Token模型文件
 * Create by :  刘泓宾<514660094@qq.com>
 * Copyright :  copyright (c) 多客怪兽, www.dkyx.cc
 */
class CloudMarketSiteAddonToken extends CloudMarketBaseModel
{
    // 配置软删除、启用回收站
    use SoftDelete;
    protected $deleteTime = "delete_time";

    // 字段自动类型转换
    protected $type = array(

    );
    // 数据输出需要追加的属性
    protected $append = array(

    );
    public $childFields = [
      'site_id','aid'
    ];
    public function __construct(array $data = [])
    {
        parent::__construct($data);
    }


    /**
     * 增加修改全局查询范围属性函数
     * Create by :  刘泓宾<514660094@qq.com>
     * @param $scope
     * @return $this
     */
    public function setGlobalScope($scope=['alias'])
    {
        $this->globalScope = $scope;
        return $this;
    }

//
//    /**
//     * 定义自定义默认全局查询范围
//     * Create by :  刘泓宾<514660094@qq.com>
//     * @param $query \think\Model
//     * @return void
//     */
//    public function scopeAlias($query)
//    {
//        if (get_plaid()) {
//            $query->where([$this->alias . '.plaid' => get_plaid()]);
//        }
//        if (get_appid()) {
//            $query->where([$this->alias . '.appid' => get_appid()]);
//        }
//    }

    /**
     * 关联CloudMarketSite模型
     * Create by :  刘泓宾<514660094@qq.com>
     * @return \think\model\relation\BelongsTo
     */
    public function site()
    {
        return $this->belongsTo(CloudMarketSite::class, 'site_id', 'id');
    }

    /**
     * 关联CloudMarketAddon模型
     * Create by :  刘泓宾<514660094@qq.com>
     * @return \think\model\relation\BelongsTo
     */
    public function addon()
    {
        return $this->belongsTo(CloudMarketAddon::class, 'aid', 'id');
    }

}
